function t(t, e, a) {
    return e in t ? Object.defineProperty(t, e, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = a, t;
}

function e(t) {
    t.setData({
        showModalStatus: !1
    }), setTimeout(function () {
        t.setData({
            mengshow: !1,
            bottom: "-100%"
        });
    }, 100);
}

function a(t) {
    for (var e = "", a = t.split("~"), r = [], o = [], i = [], c = 0; c < a.length; c++) {
        var s = a[c].match(/(\d*)\-(\d+)\-(\d+)/i);
        console.log("v", s), i.push(s[3]), n(s[2], o) ? r.push(parseInt(s[3]) + "日") : (o.push(s[2]),
            e = s[1] + "年", r.push(parseInt(s[2]) + "月" + parseInt(s[3]) + "日"));
    }
    return console.log("day", i), o.length > 1 ? e : i.length > 1 && parseInt(i[1]) - parseInt(i[0]) >= 27 ? parseInt(o[0]) + "月" : r.join("-");
}

function n(t, e) {
    for (var a in e)
        if (e[a] == t) return !0;
    return !1;
}

function r(t) {
    return String.fromCharCode(t);
}

function o(t, e) {
    var a = 3;
    e && "gb" === e.substr(0, 2).toLowerCase() && (a = 2);
    for (var n = 0, r = t.split(""), o = 0; o < r.length; o++) {
        var i = encodeURI(r[o]);
        n += 1 == i.length ? 1 : i.length / 9 * a;
    }
    return n;
}

function i(t) {
    var e = t;
    if (3 == e.length) var a = e.map(function (t) {
        return "%" + t.toString(16);
    }).join("");
    return decodeURI(a);
}

function c(t) {
    "undefined" == String(t) && (t = "");
    for (var e = new Array(), a = 0, n = 0; n < t.length; n++) {
        var r = encodeURI(t[n]);
        if (1 == r.length) e[a++] = r.charCodeAt(0);
        else
            for (var o = r.split("%"), i = 1; i < o.length; i++) e[a++] = parseInt("0x" + o[i]);
    }
    return e;
}

function s(t, e, a, n) {
    if (0 == a) return "";
    0 == n && (n = 1);
    var r = (t.substr(e, a) - n) / (n % 7 == 0 ? 1 : n % 7);
    return r < 1 ? 1 : r;
}

function l(t, e) {
    var a, t = t || " ";
    if ("" == (e = e || "")) return "";
    var n = t.length,
        r = e.length,
        o = a = !1;
    0 === e.indexOf(t) && (o = !0), e.lastIndexOf(t) === r - n && (a = !0);
    var i = e;
    return a ? i.length > 0 ? (i = i.substring(0, r - n), l(t, i)) : "" : o ? i.length > 0 ? (i = i.substring(n, i.length),
        l(t, i)) : "" : i;
}

var u = function (t) {
        return [(t = t || new Date()).getFullYear(), t.getMonth() + 1, t.getDate()].map(d).join("");
    },
    d = function (t) {
        return (t = t.toString())[1] ? t : "0" + t;
    },
    f = "https://api.xzw.com/com/json/";

module.exports = {
    formatTime: function (t) {
        var e = t.getFullYear(),
            a = t.getMonth() + 1,
            n = t.getDate(),
            r = t.getHours(),
            o = t.getMinutes(),
            i = t.getSeconds();
        return [e, a, n].map(d).join("/") + " " + [r, o, i].map(d).join(":");
    },
    formatDate: u,
    showModal: function (t) {
        t.setData({
            modalHidden: !0,
            showModalStatus: !0,
            mengshow: !0,
            bottom: "0px"
        });
    },
    hideModal: e,
    setIcon: function (t, a) {
        t.setData({
            female: t.data.femalecheck,
            male: t.data.malecheck,
            femaleclickid: t.data.femalecheck,
            maleclickid: t.data.malecheck
        });
        var n = {};
        n.m = t.data.malecheck, n.f = t.data.femalecheck, wx.setStorage({
            key: a,
            data: n
        }), e(t);
    },
    cancel: function (t) {
        t.setData({
            femalecheck: t.data.female,
            malecheck: t.data.male,
            femaleclickid: t.data.female,
            maleclickid: t.data.male
        }), e(t);
    },
    scrollFun: function (e, a) {
        var n = a.currentTarget.dataset.name,
            r = a.detail.scrollTop,
            o = a.detail.scrollHeight,
            i = Math.round(r / (o / 14));
        i > 11 && (i = 11), i < 0 && (i = 0), e.setData(t({}, n, i));
    },
    clickIcon: function (e, a) {
        var n, r = a.currentTarget.dataset.index,
            o = a.currentTarget.dataset.name,
            i = o + "check",
            c = o + "clickid";
        e.setData((n = {}, t(n, i, r), t(n, c, r), n));
    },
    getData: function (t, e, n, r) {
        var o, i = e.data.list[t - 1].name,
            c = (e.data.id, []);
        if ("xz" === n) {
            var s = u();
            o = f + "fortune.js?id=" + t + "&ld=-1&vc=xcx&token=Mh8tGmSoW3fyH642Y+Eb3E&rq=" + s;
        }
        "sx" === n && (o = f + "shengxiao.js?id=" + t + "&vc=xcx&token=Mh8tGmbZpzSxqPGmJaKeKo"),
            "sxys" === n && (o = f + "shengxiao_fortune.js?id=" + t + "&vc=wxcode&token=Mdozp+aZobSx2jK0JeglmiYkHqpuWeT3JzStGWapYqe"),
            wx.request({
                url: o,
                success: function (n) {
                    for (var o = n.data.data, s = 0; s < o.length; s++) c.push(a(o[s].vdate));
                    e.setData({
                        infodata: n.data.data,
                        id: t,
                        name: i,
                        date: c
                    }), "function" == typeof r && r();
                }
            });
    },
    getPairData: function (t, e, a) {
        var n = parseInt(t.data.male),
            r = parseInt(t.data.female);
        t.setData({
            male: n,
            female: r
        }), wx.request({
            url: f + ("sx" === e ? "shengxiao_pairs" : "pair") + ".js?aid=" + (n + 1) + "&bid=" + (r + 1) + "&vc=" + ("sx" === e ? "smart" : "xcx") + "&token=" + ("sx" === e ? "MZnl52boobgxX242Y9mmqSQkG2ZxHx/1pzSr3E" : "Mh8tGmbe3rWx52foQ"),
            success: function (e) {
                var n = e.data.data.data;
                t.setData({
                    infodata: n
                }), "function" == typeof a && a();
            }
        });
    },
    initdata: function (t, e) {
        var a = wx.getStorageSync(e);
        a && t.setData({
            male: a.m,
            malecheck: a.m,
            maleclickid: a.m,
            female: a.f,
            femalecheck: a.f,
            femaleclickid: a.f
        });
    },
    simple_date: a,
    getPairTopData: function (t, e, a, n) {
        wx.request({
            url: f + ("sx" === e ? "shengxiao_" : "") + "pairtop.js?id=" + a + "&vc=smart&token=" + ("sx" === e ? "MZnl52boobgxX242Y9mmqSQkG2ZxHx/1pzStKqbeXKe" : "MZnl52boobdvY3O3Zl6a6s"),
            success: function (e) {
                var a = e.data.data.data;
                t.setData({
                    infodata: a
                }), "function" == typeof n && n();
            }
        });
    },
    authcode: function () {
        var t, e, a, n = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null,
            s = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "encode",
            l = o(n += "");
        if ("decode" == s) {
            if (l % 3 != 0) return "";
            l /= 3;
        }
        e = [], a = "";
        for (var u = 0, d = 0; d < 255; d++) u = (u + d) % 26, t = d, e[d] = u, e[u] = t;
        var f = "",
            m = [];
        "encode" == s && (f = c(n));
        for (var g = u = d = 0; d < l; d++)
            if (g = (g + 1) % 255, u = (u + e[g]) % 255,
                t = g, e[g] = u, e[u] = t, "encode" == s) {
                var h = f[d] + e[(e[g] + e[u]) % 200];
                h < 100 && (h = "0" + h), a += h;
            } else {
                var v = Math.ceil(n.substr(3 * d, 3) - e[(e[g] + e[u]) % 200]);
                v > 127 ? (m.push(v), 3 == m.length && (a += i(m), m = [])) : a += r(v);
            }
        return a;
    },
    formatCxLink: function (t, e) {
        var a;
        0 == (a = isNaN(t) ? t.length : t) && (a = 1);
        var n = a % 7;
        0 == n && (n = 1);
        for (var r = [], o = [0, 0, 0, 0], i = 0; i < e.length; i++) e[i] && (r[i] = e[i] * n + a,
            o[i] = r[i].toString().length);
        return o.join("") + r.join("");
    },
    GetCxId: function (t, e) {
        var a, n, e, r, o, i, c, u, d, f = String(t).substr(0, 4);
        return a = String(t).substr(4), n = isNaN(e) ? trlen2(e) : e, a && (r = s(a, 0, f[0], n),
                o = s(a, f[0], f[1], n), i = s(a, f[1] + f[0], f[2], n), c = s(a, f[1] + f[0] + f[2], f[3], n)),
            u = [r, o, i, c], d = u.join("|"), (u = l("|", d)).split("|");
    },

    /**
     * 推送小程序页面SEO
     * 使用的前提是APP.JS已把access_token存到本地了
     * @param {*} path  推送路径 如: pages/index/index
     * @param {*} param  推送参数 name=xiongzhu&age=18 
     */
    putSeo: function (path, param) {
        if (typeof (param) == 'object') {
            var new_param = '';
            for (var index in param) {
                new_param = new_param + index + '=' + param[index] + '&';
            }
            new_param = new_param.slice(new_param, -1);
        } else {
            new_param = param;
        }
        var access_token = wx.getStorageSync('access_token');
        access_url = "https://api.weixin.qq.com/wxa/search/wxaapi_submitpages?access_token=" + access_token; //请求的url
        access_param = {
            "pages": [{
                "path": path + '.html',
                "query": new_param
            }]
        }
        wx.request({
            url: access_url,
            data: access_param,
            method: 'post',
            success: function (e) {
                console.log(e);
            },
            fail: function (e) {
                console.log(e);
            },
        })
    }
};